package com.hmy.infrastructure.client.alimeas;

import com.hmy.ccp.common.result.FeignResult;
import com.hmy.ccp.common.result.Results;
import com.hmy.ccp.error.annotations.HmyFeignController;
import com.hmy.infrastructure.api.bo.request.aliemaspush.MessageAccountPushRequest;
import com.hmy.infrastructure.api.bo.request.aliemaspush.MessageDevicePushRequest;
import com.hmy.infrastructure.api.client.aliemas.EmasPushClient;
import com.hmy.infrastructure.service.aliemas.IAliEmasPushService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@Api(tags = "移动消息推送服务")
@Validated
@RestController("emasPushController")
@Slf4j
@HmyFeignController
public class EmasPushController implements EmasPushClient {

    @Resource
    private IAliEmasPushService iAliEmasPushService;

    @Override
    @PostMapping("/feign/emas/sendMessageByDevices")
    public FeignResult<Boolean> sendMessageByDevices(@Validated @RequestBody MessageDevicePushRequest messageDevicePushRequest) {
        return Results.newSuccessResult(iAliEmasPushService.sendMessageByDevices(messageDevicePushRequest));
    }
    
    @Override
    @PostMapping("/feign/emas/sendMessageByAccounts")
    public FeignResult<Boolean> sendMessageByAccounts(@Validated @RequestBody MessageAccountPushRequest messageAccountPushRequest) {
        return Results.newSuccessResult(iAliEmasPushService.sendMessageByAccounts(messageAccountPushRequest));
    }

}
